package com.gitee.gen.inittable;


import cn.shoukaiseki.inittable.ITableBuildInfoService;
import cn.shoukaiseki.inittable.annotation.TableBuild;
import cn.shoukaiseki.inittable.domain.TableColumnInfo;
import cn.shoukaiseki.inittable.utils.TableColumnInfoBuilder;
import cn.shoukaiseki.inittable.utils.TableInfoUtils;

import java.util.List;

@TableBuild(name = "gen_table", comment = "代码生成业务表",version = 1)
public class GenTableInitTableInfo implements ITableBuildInfoService {


    @Override
    public List<TableColumnInfo> tableColumnInfoList(){
        List<TableColumnInfo> table = TableInfoUtils.tableColumns(
                TableColumnInfoBuilder.column("  tableId bigint NOT NULL auto_increment COMMENT '编号',")
                .primaryKey(),
                TableColumnInfoBuilder.column("  tableName varchar(200) DEFAULT '' COMMENT '表名称',"),
                TableColumnInfoBuilder.column("  tableComment varchar(500) DEFAULT '' COMMENT '表描述',"),
                TableColumnInfoBuilder.column("  className varchar(100) DEFAULT '' COMMENT '实体类名称',"),
                TableColumnInfoBuilder.column("  tplCategory varchar(200) DEFAULT 'crud' COMMENT '使用的模板（crud单表操作 tree树表操作）',"),
                TableColumnInfoBuilder.column("  packageName varchar(100) DEFAULT NULL COMMENT '生成包路径',"),
                TableColumnInfoBuilder.column("  moduleName varchar(64) DEFAULT NULL COMMENT '生成模块名',"),
                TableColumnInfoBuilder.column("  businessName varchar(64) DEFAULT NULL COMMENT '生成业务名',"),
                TableColumnInfoBuilder.column("  functionName varchar(64) DEFAULT NULL COMMENT '生成功能名',"),
                TableColumnInfoBuilder.column("  functionAuthor varchar(50) DEFAULT NULL COMMENT '生成功能作者',"),
                TableColumnInfoBuilder.column("  genType char(1) DEFAULT '0' COMMENT '生成代码方式（0zip压缩包 1自定义路径）',"),
                TableColumnInfoBuilder.column("  genPath varchar(200) DEFAULT '/' COMMENT '生成路径（不填默认项目路径）',"),
                TableColumnInfoBuilder.column("  options varchar(1000) DEFAULT NULL COMMENT '其它生成选项',"),

                TableColumnInfoBuilder.column("  mybatisTableAlias varchar(64) DEFAULT 't1' not NULL COMMENT 'mybatis查询时表别名',")
                .description("${tableName} as ${mybatisTableAlias}"),


                TableColumnInfoBuilder.column("  createBy varchar(64) DEFAULT '' COMMENT '创建者',"),
                TableColumnInfoBuilder.column("  createTime datetime DEFAULT NULL COMMENT '创建时间',"),
                TableColumnInfoBuilder.column("  updateBy varchar(64) DEFAULT '' COMMENT '更新者',"),
                TableColumnInfoBuilder.column("  updateTime datetime DEFAULT NULL COMMENT '更新时间',"),
                TableColumnInfoBuilder.column("  remark varchar(500) DEFAULT NULL COMMENT '备注',"),
                TableColumnInfoBuilder.column("  virtualDelete char(1) DEFAULT '0' COMMENT '虚拟删除',"),
                TableColumnInfoBuilder.column("  resourceConfName  varchar(64) DEFAULT '' not null COMMENT '资源配置名称',"),
                null
        );

        return table;
    }

//    @Override
//    public List<TableIndexInfo> tableIndexInfoList() {
//        return tableIndexs(
//                index("inventory_reserved_inventory_bom_id_index").indexColumns("inventory_bom_id"),
//                index("inventory_reserved_item_id_index").indexColumns("item_id"),
//                index("inventory_reserved_inventory_bom_item_id_index").indexColumns("inventory_bom_id,item_id"),
//                null
//        );
//    }
//
//    @Override
//    public List<TableTriggerInfo> tableTriggerList() {
//        return tableTriggers(triggerName("inventory_reserved_rowstamp")
//                .triggerSql("create trigger inventory_reserved_rowstamp before update on inventory_reserved FOR EACH ROW\n" +
//                        "begin\n" +
//                        "    set @rowstamp= old.rowstamp;\n" +
//                        "    set NEW.rowstamp=@rowstamp+1;\n" +
//                        "end;\n"));
//    }
}
